package kr.co.doriclassic.mypuppystory.searchpuppy;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;

public abstract class Parser<T> {

	abstract ArrayList<T> parseItem(String url);

	public XmlPullParser connInfo(String url) {
		URL targetURL = null;
		XmlPullParser parser = null;
		try {
			targetURL = new URL(url);
			InputStream is = targetURL.openStream();
			// Parser
			XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
			parser = factory.newPullParser();
			parser.setInput(is, "utf-8");
		} catch (XmlPullParserException | IOException e) {
			e.printStackTrace();
		}
		return parser;
	}
}
